﻿package {
	import flash.display.Sprite;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	import flash.events.MouseEvent;
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	import flash.filters.*;
	class llkBtn extends Sprite {
		private var txtfld1:TextField;
		private var txtfld2:TextField;
		private var btnBg:buttonBG;
		private var bgTimer:Timer;
		private var bigBG:BigBG;
		private var newFormat:TextFormat = new TextFormat();
		private var newFormat1:TextFormat = new TextFormat();
		public function llkBtn(x:Number,y:Number,mouse:Boolean,bg:Boolean=false ,bgx:int=0, bgwidth:int=0):void {
			btnBg=new buttonBG();
			if (bg) {
				addChild(btnBg);
				btnBg.x=bgx;//(txtfld1.width+ww)/2-2;
				btnBg.y=10;
				btnBg.width=bgwidth;//(txtfld1.width+ww)*1.4;
				btnBg.height=50;//txtfld1.height*2.6;
				this.addEventListener(MouseEvent.ROLL_OVER,rollover);
				this.addEventListener(MouseEvent.ROLL_OUT,rollout);
			}
			newFormat.color=0xDF1A62;
			newFormat.size=14;
			newFormat.bold=true;
			newFormat1.color=0xFFFFFF;
			newFormat1.size=12;
			newFormat1.bold=true;
			txtfld1=createtxtfld();
			txtfld2=createtxtfld();
			var filter1:BevelFilter  = new BevelFilter ();
			filter1.shadowColor=0xFFFFFF;
			filter1.highlightColor=0xDF1A62;
			filter1.type=BitmapFilterType.OUTER;
			filter1.distance=1;
			filter1.blurX=0;
			filter1.blurY=0;
			filter1.quality=BitmapFilterQuality.HIGH;
			txtfld1.filters=[filter1];
			this.x=x;
			this.y=y;
			addChild(txtfld1);
			addChild(txtfld2);
			if (mouse) {
				this.buttonMode=true;
				this.mouseChildren=false;
			}
			bgTimer=new Timer(10);
			bgTimer.addEventListener(TimerEvent.TIMER,ontime);
		}
		private function rollover(e:MouseEvent):void {
			var filter1:BevelFilter  = new BevelFilter ();
			filter1.shadowColor=0xDF1A62;
			filter1.highlightColor=0xFFFFFF;
			filter1.type=BitmapFilterType.OUTER;
			filter1.distance=1;
			filter1.blurX=0;
			filter1.blurY=0;
			filter1.quality=BitmapFilterQuality.HIGH;
			txtfld1.filters=[filter1];
			bgTimer.start();
		}
		private function rollout(e:MouseEvent):void {
			var filter1:BevelFilter  = new BevelFilter ();
			filter1.shadowColor=0xFFFFFF;
			filter1.highlightColor=0xDF1A62;
			filter1.type=BitmapFilterType.OUTER;
			filter1.distance=1;
			filter1.blurX=0;
			filter1.blurY=0;
			filter1.quality=BitmapFilterQuality.HIGH;
			txtfld1.filters=[filter1];
			bgTimer.stop();
		}
		private function ontime(e:TimerEvent) {
			btnBg.rotatemc.rotation+=1;
			if (btnBg.rotatemc.rotation==360) {
				btnBg.rotatemc.rotation=0;
			}
		}
		public function get text():String {
			return txtfld1.text;
		}
		public function set text(s:String):void {
			txtfld1.text=s;
			txtfld1.setTextFormat(newFormat1);
			txtfld2.x=txtfld1.width+3;
			txtfld2.y=-2;
		}
		public function set text2(s:String):void {
			txtfld2.text=s;
			txtfld2.setTextFormat(newFormat);
		}
		private function createtxtfld(xx:Number=0, yy:Number=0):TextField {
			var t:TextField=new TextField();
			t.x=xx;
			t.y=yy;
			t.autoSize=TextFieldAutoSize.LEFT;
			t.selectable=false;
			return t;
		}
	}
}